<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
</head>

<body>
    <div>
        <input type="text" placeholder="请输入要查找的关键词" name="keyword">
        <input type="button" value="查询" onclick="btnQuery()">
        <input type="button" value="增加" onclick="btnAdd()">
    </div>
    <table id="tbData">
        <tr>
            <th>id</th>
            <th>标题</th>
            <th>摘要</th>
            <th>内容</th>
            <th>分类</th>
            <th>作者</th>
            <th>发表时间</th>
            <th>操作</th>
        </tr>
    </table>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./config/baseUrl.js"></script>
    <script src="./js/api.js"></script>
    <script src="./js/init.js"></script>
    <script>
        function btnAdd() {
            window.location.href = `./addOrEdit.html`;
        }
        function btnEdit(id) {
            window.location.href = `./addOrEdit.html?id=` + id;
        }
        function btnDel(id) {
            if (confirm("你要删除这个吗？")) {
                delProduct(id).then(res => {
                    if (res.code === 1000) {
                        $(`[key=${id}]`).remove();
                    } else {
                        alert(res.msg);
                    }
                })
            }
        }
        function btnQuery() {
            let keyword = $('[name=keyword]').val();
            getListWithKeyword(keyword);
        }
    </script>
</body>

</html>